package com.superteam.zzl.adapter;

import android.content.Context;
import android.databinding.DataBindingUtil;
import android.view.View;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.superteam.zzl.activity.databinding.ActivityAuthorFootLvBinding;
import com.superteam.zzl.model.DynamicFragment.bean.Dynamic;

import java.util.List;

import jp.wasabeef.glide.transformations.CropCircleTransformation;

/**
 * Created by Administrator on 2017/1/11.
 */

public class AuthorActivityFootAdapter extends MyBaseAdapter<Dynamic.DataBean.TrendsListBean.CommentListBean, AuthorActivityFootAdapter.ViewHolder> {


    public AuthorActivityFootAdapter(Context context, List<Dynamic.DataBean.TrendsListBean.CommentListBean> list, int resId) {
        super(context, list, resId);
    }

    @Override
    public ViewHolder bindView(View convertView, List<Dynamic.DataBean.TrendsListBean.CommentListBean> list, int position) {
        return new ViewHolder(convertView);
    }

    @Override
    public void bindData(ViewHolder viewHolder, List<Dynamic.DataBean.TrendsListBean.CommentListBean> list, int position) {
        Dynamic.DataBean.TrendsListBean.CommentListBean comment = list.get(position);
        viewHolder.getBinding().setComment(comment);
        BitmapPool bitmapPool = Glide.get(context).getBitmapPool();
        Glide.with(context).load(comment.getAvatar()).bitmapTransform(new CropCircleTransformation(bitmapPool)).into(viewHolder.getBinding().iv);
        viewHolder.getBinding().executePendingBindings();
    }


    class ViewHolder extends MyBaseAdapter.BaseHolder {

        private ActivityAuthorFootLvBinding db;

        public ViewHolder(View convertView) {
            db = DataBindingUtil.bind(convertView);
        }

        public ActivityAuthorFootLvBinding getBinding() {
            return db;
        }
    }
}
